<template>
  <el-button @click="handleReview" v-bind="$attrs">
    <slot>查看</slot>
  </el-button>
</template>
<script>
  // Util.encodeToURIString()
  import { mapGetters } from 'vuex'
  import { noticeUrl } from '@/settings'

  export default {
    props: {
      id: [Number, String]
    },
    computed: {
      ...mapGetters({
        token: 'user/token'
      })
    },
    methods: {
      handleReview() {
        if (!this.id || !this.token) return
        const params = {
          id: this.id
          // tk: this.token
        }
        sessionStorage.setItem('ntc', JSON.stringify(this.token))
        window.open(noticeUrl + '?' + Util.encodeToURIString(params))
      }
    }
  }
</script>
